package com.explore.demo.controller;


import com.explore.demo.common.ServerResponse;
import com.explore.demo.pojo.Department;
import com.explore.demo.pojo.HumanSource;
import com.explore.demo.service.DepartmentService;
import com.explore.demo.service.HumanSourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.catalina.Server;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.InetAddress;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gaolainan
 * @since 2021-04-18
 */
@RestController
@RequestMapping("/human_source")
public class HumanSourceController {
    @Resource
    private HumanSourceService humanSourceService;

    @GetMapping
    @ApiOperation("查询全部hr的信息")
    public ServerResponse query(){
        return humanSourceService.queryAll();
    }

    @PostMapping
    @ApiOperation("创建一个hr的信息")
    public ServerResponse addOne(HumanSource humanSource){
        return humanSourceService.addHumanSource(humanSource);
    }

    @DeleteMapping
    @ApiOperation("通过hr的姓名 删除hr的相关信息")
    public ServerResponse deleteByName(String realName){
        return humanSourceService.deleteByRealName(realName);
    }

    @PostMapping("/{realName}")
    @ApiOperation("通过hr的姓名 查询hr的相关信息")
    public ServerResponse queryByName(@PathVariable("realName") String realName){
        return humanSourceService.queryByRealName(realName);
    }

    @PostMapping("/own")
    @ApiOperation("查询自己创建的职位")
    public ServerResponse showOneRecruitment(HttpServletRequest request){
        return humanSourceService.showOwnRecruitment(request);
    }

    @PostMapping("/login")
    @ApiOperation("Hr用来登陆的接口")
    public ServerResponse showOneRecruitment(@RequestParam("account") String account,@RequestParam("password") String password){
        return humanSourceService.humanLogin(account, password);
    }

    @PostMapping("/get_delivery")
    @ApiOperation("获得hr发出的职位 别人投递的记录")
    public ServerResponse getDeliveryList(HttpServletRequest request){
        return humanSourceService.getDeliveryLogs(request);
    }

    @PostMapping("/download")
    @ApiOperation("下载对应的简历 根据id")
    public ServerResponse downloadResume(Integer id, HttpServletResponse response) throws IOException
    {
        return humanSourceService.downloadResume(id, response);
    }


    @PostMapping("/list")
    @ApiOperation("获得当前hr发布的职位招聘信息")
    public ServerResponse listRecruitment(HttpServletRequest request){
        return humanSourceService.listRecruitment(request);
    }

    @PostMapping("/search")
    @ApiOperation("根据内容检索对应的招聘信息")
    public ServerResponse searchByInfo(String info, HttpServletRequest request){
        return humanSourceService.searchByRecruitmentName(info, request);
    }

    @PostMapping("/get_company")
    @ApiOperation("获得自己在职的公司的信息")
    public ServerResponse getCompanyInfo(HttpServletRequest request){
        return humanSourceService.getOwnCompanyInfo(request);
    }

    @PostMapping("/register")
    @ApiOperation("注册hr的账号信息")
    public ServerResponse register(@RequestParam("account") String account,@RequestParam("password") String password,@RequestParam("realName") String realName,  HttpServletRequest request){
        return humanSourceService.register(account, password, realName, request);
    }

    @PostMapping("/search_log")
    @ApiOperation("根据内容检索对应的投递记录")
    public ServerResponse searchByDeliveryLog(String info, HttpServletRequest request){
        return humanSourceService.searchDeliveryLogByUserName(info, request);
    }
}

